package com.trace.pplos.parse.dao.dataobject;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Date;

public class ZdryInfo {
    private static final Logger logger = LoggerFactory.getLogger(ZdryInfo.class);

    private Integer id;

    private String billNo;

    private String psnType;

    private String idNo;

    private String name;

    private String sex;

    private String addr;

    private String des;

    private String photoPath;

    private String lng;

    private String lat;

    private String synced;

    private String lngGps;

    private String latGps;

    private String checkReason;

    private String nation;

    private String censusRegister;

    private String positionPhotoPath;

    private String telI;

    private String telIi;

    private String telIii;

    private String locAddr;

    private String signalStation;

    private String cjdw;

    private String filepath;

    private String voicePath;

    private String voiceDisplayNames;

    private Date gmtCreate;

    private String gmtCreateUser;

    private Date gmtModified;

    private String gmtModifiedUser;

    private Integer status;

    public ZdryInfo(Integer id, String billNo, String psnType, String idNo, String name, String sex, String addr, String des, String photoPath, String lng, String lat, String synced, String lngGps, String latGps, String checkReason, String nation, String censusRegister, String positionPhotoPath, String telI, String telIi, String telIii, String locAddr, String signalStation, String cjdw, String filepath, String voicePath, String voiceDisplayNames, Date gmtCreate, String gmtCreateUser, Date gmtModified, String gmtModifiedUser, Integer status) {
        this.id = id;
        this.billNo = billNo;
        this.psnType = psnType;
        this.idNo = idNo;
        this.name = name;
        this.sex = sex;
        this.addr = addr;
        this.des = des;
        this.photoPath = photoPath;
        this.lng = lng;
        this.lat = lat;
        this.synced = synced;
        this.lngGps = lngGps;
        this.latGps = latGps;
        this.checkReason = checkReason;
        this.nation = nation;
        this.censusRegister = censusRegister;
        this.positionPhotoPath = positionPhotoPath;
        this.telI = telI;
        this.telIi = telIi;
        this.telIii = telIii;
        this.locAddr = locAddr;
        this.signalStation = signalStation;
        this.cjdw = cjdw;
        this.filepath = filepath;
        this.voicePath = voicePath;
        this.voiceDisplayNames = voiceDisplayNames;
        this.gmtCreate = gmtCreate;
        this.gmtCreateUser = gmtCreateUser;
        this.gmtModified = gmtModified;
        this.gmtModifiedUser = gmtModifiedUser;
        this.status = status;
    }

    public ZdryInfo() {
        super();
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getBillNo() {
        return billNo;
    }

    public void setBillNo(String billNo) {
        this.billNo = billNo == null ? null : billNo.trim();
    }

    public String getPsnType() {
        return psnType;
    }

    public void setPsnType(String psnType) {
        this.psnType = psnType == null ? null : psnType.trim();
    }

    public String getIdNo() {
        return idNo;
    }

    public void setIdNo(String idNo) {
        this.idNo = idNo == null ? null : idNo.trim();
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name == null ? null : name.trim();
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex == null ? null : sex.trim();
    }

    public String getAddr() {
        return addr;
    }

    public void setAddr(String addr) {
        this.addr = addr == null ? null : addr.trim();
    }

    public String getDes() {
        return des;
    }

    public void setDes(String des) {
        this.des = des == null ? null : des.trim();
    }

    public String getPhotoPath() {
        return photoPath;
    }

    public void setPhotoPath(String photoPath) {
        this.photoPath = photoPath == null ? null : photoPath.trim();
    }

    public String getLng() {
        return lng;
    }

    public void setLng(String lng) {
        this.lng = lng == null ? null : lng.trim();
    }

    public String getLat() {
        return lat;
    }

    public void setLat(String lat) {
        this.lat = lat == null ? null : lat.trim();
    }

    public String getSynced() {
        return synced;
    }

    public void setSynced(String synced) {
        this.synced = synced == null ? null : synced.trim();
    }

    public String getLngGps() {
        return lngGps;
    }

    public void setLngGps(String lngGps) {
        this.lngGps = lngGps == null ? null : lngGps.trim();
    }

    public String getLatGps() {
        return latGps;
    }

    public void setLatGps(String latGps) {
        this.latGps = latGps == null ? null : latGps.trim();
    }

    public String getCheckReason() {
        return checkReason;
    }

    public void setCheckReason(String checkReason) {
        this.checkReason = checkReason == null ? null : checkReason.trim();
    }

    public String getNation() {
        return nation;
    }

    public void setNation(String nation) {
        this.nation = nation == null ? null : nation.trim();
    }

    public String getCensusRegister() {
        return censusRegister;
    }

    public void setCensusRegister(String censusRegister) {
        this.censusRegister = censusRegister == null ? null : censusRegister.trim();
    }

    public String getPositionPhotoPath() {
        return positionPhotoPath;
    }

    public void setPositionPhotoPath(String positionPhotoPath) {
        this.positionPhotoPath = positionPhotoPath == null ? null : positionPhotoPath.trim();
    }

    public String getTelI() {
        return telI;
    }

    public void setTelI(String telI) {
        this.telI = telI == null ? null : telI.trim();
    }

    public String getTelIi() {
        return telIi;
    }

    public void setTelIi(String telIi) {
        this.telIi = telIi == null ? null : telIi.trim();
    }

    public String getTelIii() {
        return telIii;
    }

    public void setTelIii(String telIii) {
        this.telIii = telIii == null ? null : telIii.trim();
    }

    public String getLocAddr() {
        return locAddr;
    }

    public void setLocAddr(String locAddr) {
        this.locAddr = locAddr == null ? null : locAddr.trim();
    }

    public String getSignalStation() {
        return signalStation;
    }

    public void setSignalStation(String signalStation) {
        this.signalStation = signalStation == null ? null : signalStation.trim();
    }

    public String getCjdw() {
        return cjdw;
    }

    public void setCjdw(String cjdw) {
        this.cjdw = cjdw == null ? null : cjdw.trim();
    }

    public String getFilepath() {
        return filepath;
    }

    public void setFilepath(String filepath) {
        this.filepath = filepath == null ? null : filepath.trim();
    }

    public String getVoicePath() {
        return voicePath;
    }

    public void setVoicePath(String voicePath) {
        this.voicePath = voicePath == null ? null : voicePath.trim();
    }

    public String getVoiceDisplayNames() {
        return voiceDisplayNames;
    }

    public void setVoiceDisplayNames(String voiceDisplayNames) {
        this.voiceDisplayNames = voiceDisplayNames == null ? null : voiceDisplayNames.trim();
    }

    public Date getGmtCreate() {
        return gmtCreate;
    }

    public void setGmtCreate(Date gmtCreate) {
        this.gmtCreate = gmtCreate;
    }

    public String getGmtCreateUser() {
        return gmtCreateUser;
    }

    public void setGmtCreateUser(String gmtCreateUser) {
        this.gmtCreateUser = gmtCreateUser == null ? null : gmtCreateUser.trim();
    }

    public Date getGmtModified() {
        return gmtModified;
    }

    public void setGmtModified(Date gmtModified) {
        this.gmtModified = gmtModified;
    }

    public String getGmtModifiedUser() {
        return gmtModifiedUser;
    }

    public void setGmtModifiedUser(String gmtModifiedUser) {
        this.gmtModifiedUser = gmtModifiedUser == null ? null : gmtModifiedUser.trim();
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public static ZdryInfo toBean(String object) {
        try {
            ZdryInfo info = new ZdryInfo();
            JSONObject record = JSON.parseObject(object);
            info.setSynced("0");
            info.setPsnType(record.getString("rylx"));
            info.setIdNo(record.getString("sfzh"));
            info.setName(record.getString("rymc"));
            /*info.setSex(record.getString());*/
            info.setAddr(record.getString("xjdz"));
            info.setDes(record.getString("ryms"));

            //信息资料
            String photoPath = "";
            JSONArray photoPathlist = record.getJSONArray("xxzlPictureList");
            for (int i = 0; i < photoPathlist.size(); i++) {
                JSONObject dataObj = photoPathlist.getJSONObject(i);
                photoPath += dataObj.getString("path") + ",";
            }
            info.setPhotoPath(photoPath);

            info.setLng(record.getString("longitude"));
            info.setLat(record.getString("latitude"));
            info.setLngGps(record.getString("longitude"));
            info.setLatGps(record.getString("latitude"));
            /*info.setCheckReason(record.getString());*/
            info.setNation(record.getString("ssmz"));
            info.setCensusRegister(record.getString("hjdz"));

            //现场方位
            String positionPhotoPath = "";
            JSONArray positionPhotoPathlist = record.getJSONArray("xcfwPictureList");
            for (int i = 0; i < positionPhotoPathlist.size(); i++) {
                JSONObject dataObj = positionPhotoPathlist.getJSONObject(i);
                positionPhotoPath += dataObj.getString("path") + ",";
            }
            info.setPositionPhotoPath(record.getString("positionPhotoPath"));

            info.setTelI(record.getString("dhhm"));
            info.setTelIi(record.getString("dhhm"));
            info.setTelIii(record.getString("dhhm"));
            info.setLocAddr(record.getString("address"));


         /*   info.setCjdw(record.getString());
            info.setFilepath(record.getString());*/
            //语音地址
            String voicePath = "";
            String voiceDisplayNames = "";
            JSONArray voicePathlist = record.getJSONArray("voiceList");
            for (int i = 0; i < voicePathlist.size(); i++) {
                JSONObject dataObj = voicePathlist.getJSONObject(i);
                voicePath += dataObj.getString("path") + ",";
                voiceDisplayNames += dataObj.getString("name") + ",";
            }
            info.setVoicePath(voicePath);
            info.setVoiceDisplayNames(voiceDisplayNames);

            info.setGmtCreate(record.getDate("createdAt"));
            info.setGmtCreateUser(record.getString("createdBy"));
            //info.setGmtModified(record.getDate("modifiedAt"));
            info.setGmtModified(new Date());
            info.setGmtModifiedUser(record.getString("modifiedBy"));
            return info;
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
        }
        return null;
    }
}